const {ccclass, property} = cc._decorator;
import roundMask from './roundMask'
@ccclass
export default class test extends cc.Component {

    @property(cc.Label)
    label: cc.Label = null;
    @property(roundMask)
    mask:roundMask = null;
    type:boolean = true;
    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    start () {
    }
    updateLab(){
        let num = 4;
        if(this.mask.Angle1){
            num--;
        }
        if(this.mask.Angle2){
            num--;
        }
        if(this.mask.Angle3){
            num--;
        }
        if(this.mask.Angle4){
            num--;
        }
        this.label.string = num.toString();
    }

    update (dt) {
        this.updateLab();
    }
    Callbacks(){
        let a = [];
        a.push(this.mask.Angle1);
        a.push(this.mask.Angle2);
        a.push(this.mask.Angle3);
        a.push(this.mask.Angle4);
        let firstTrue =  a.indexOf(this.type);
        if(firstTrue == -1){
            this.type = !this.type;
            this.mask.Angle1 = !this.mask.Angle1;
        }else{
            switch(firstTrue){
                case 0:this.mask.Angle1 = !this.mask.Angle1;break;
                case 1:this.mask.Angle2 = !this.mask.Angle2;break;
                case 2:this.mask.Angle3 = !this.mask.Angle3;break;
                case 3:this.mask.Angle4 = !this.mask.Angle4;break;
            }
        }
    }
}
